package com.grapevine.contact.util;

import java.security.MessageDigest;

public class Md5Tool
{
	public static String getMd5Value(String src)
	{
		try
		{
			MessageDigest md5;
			md5 = MessageDigest.getInstance("MD5");
			md5.update(src.getBytes());
			byte[] value = md5.digest();
			StringBuffer buffer = new StringBuffer();

			for (int i = 0; i < value.length; i++)
			{

				String hex = Integer.toHexString(value[i] & 0xff);

				if (hex.length() == 1)
					hex = "0" + hex;
				buffer.append(hex);
			}

			return buffer.toString();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		return null;
	}
}
